package cn.tpshion.vm.domain.support;

import cn.tpshion.vm.common.constant.MsgType;
import cn.tpshion.vm.common.utils.DateUtil;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import java.io.Serializable;

@Getter
@Setter
@ToString
public class MsgData<T> implements Serializable {

    private static final long serialVersionUID = 2715825256630462175L;

    private String type;

    private String msg;

    private T data;

    private String time = DateUtil.now();

    public MsgData(MsgType msgType){
        this.type = msgType.getType();
        this.time = getTime();
    }

    public MsgData(MsgType msgType, String msg){
        this.type = msgType.getType();
        this.msg = msg;
        this.time = getTime();
    }

    public static MsgData of(MsgType msgType, String msg){
        return new MsgData(msgType, msg);
    }
}
